﻿// ===============================================================================
// PhoneRule.cs
// EOS Framework
// ===============================================================================
// Copyright (c) EOS Development Group. All rights reserved.
// ===============================================================================

namespace EOS.Framework.Rules
{
    /// <summary>
    /// Rule for phone numbers.
    /// </summary>
    public class PhoneRule : RegexRule
    {        
        /// <summary>
        /// Initializes a new instance of the <see cref="PhoneRule"/> class
        /// with a description
        /// </summary>
        /// <param name="brokenDescription">The description.</param>
        /// <exception cref="ArgumentNullException"><paramref name="brokenDescription"/> is
        /// null (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentException"><paramref name="brokenDescription"/> is a string
        /// of length 0 or contains only blanks.</exception>
        public PhoneRule(string brokenDescription)
            : this(brokenDescription, false)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="PhoneRule"/> class.
        /// </summary>
        /// <param name="brokenDescription">The description.</param>
        /// <param name="canBeEmpty">if set to <c>true</c> the value can be empty.</param>
        /// <param name="brokenDescription">The description.</param>
        /// <exception cref="ArgumentNullException"><paramref name="brokenDescription"/> is
        /// null (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentException"><paramref name="brokenDescription"/> is a string
        /// of length 0 or contains only blanks.</exception>
        public PhoneRule(string brokenDescription, bool canBeEmpty)
            : base(brokenDescription,
            "^([+][1-9][0-9]{1,2}[ ]+)?[0-9]{3,5}[ ]*[-/][ ]*[1-9][-0-9 ]{2,16}$", 
            canBeEmpty)
        { 
        }
    }
}